<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/9/18 17:00
 */

namespace module\user\model;

use mof\Model;
use think\model\relation\BelongsTo;

class InviteLog extends Model
{
    protected $name       = 'user_invite_log';
    protected $updateTime = false;

    protected array $searchFields = [
        'inviter_id' => 'integer',
        'invitee'    => 'string',
        'create_at'  => ['type' => 'datetime', 'op' => 'between']
    ];

    public function inviter(): BelongsTo
    {
        return $this->belongsTo(User::class, 'inviter_id', 'id')
            ->visible(['id', 'username', 'nickname', 'avatar']);
    }

    public function invitee(): BelongsTo
    {
        return $this->belongsTo(User::class, 'invitee_id', 'id')
            ->visible(['id', 'username', 'nickname', 'avatar']);
    }
}